import request from "@/api/index";
interface dataSourceType {
  [propName: string]: any;
}
export const checkSequrity = async (_rule: dataSourceType = {}, value: any) => {
  if (!value) {
    return Promise.reject(`${_rule.msg1}`);
  } else {
    var params = Object.assign(_rule.params, {
      name: _rule.type === 'name' ? value : '',
      level: _rule.type === 'level' ? value : '',
      secretType: _rule.secretType,
    })
    if (_rule.api) {
      let res = await request[`${_rule.api}`](params);
      if (!res) {
        return Promise.reject(`${_rule.msg2}`);
      } else {
        return Promise.resolve();
      }
    }

  }
};